var e = require;
var t = module;
var n = exports;
var o,
    i =
        (this && this.__extends) ||
        ((o = function (e, t) {
            return (o =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
                })(e, t);
        }),
        function (e, t) {
            function n() {
                this.constructor = e;
            }
            o(e, t), (e.prototype = null === t ? Object.create(t) : ((n.prototype = t.prototype), new n()));
        }),
    r =
        (this && this.__decorate) ||
        function (e, t, n, o) {
            var i,
                r = arguments.length,
                a = r < 3 ? t : null === o ? (o = Object.getOwnPropertyDescriptor(t, n)) : o;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, n, o);
            else
                for (var s = e.length - 1; 0 <= s; s--)
                    (i = e[s]) && (a = (r < 3 ? i(a) : 3 < r ? i(t, n, a) : i(t, n)) || a);
            return 3 < r && a && Object.defineProperty(t, n, a), a;
        },
    a =
        (this && this.__awaiter) ||
        function (e, a, s, c) {
            return new (s = s || Promise)(function (n, t) {
                function o(e) {
                    try {
                        r(c.next(e));
                    } catch (e) {
                        t(e);
                    }
                }
                function i(e) {
                    try {
                        r(c.throw(e));
                    } catch (e) {
                        t(e);
                    }
                }
                function r(e) {
                    var t;
                    e.done
                        ? n(e.value)
                        : ((t = e.value) instanceof s
                              ? t
                              : new s(function (e) {
                                    e(t);
                                })
                          ).then(o, i);
                }
                r((c = c.apply(e, a || [])).next());
            });
        },
    s =
        (this && this.__generator) ||
        function (n, o) {
            var i,
                r,
                a,
                s = {
                    label: 0,
                    sent: function () {
                        if ((1, 1 & a[0])) throw a[1];
                        return a[1];
                    },
                    trys: [],
                    ops: []
                },
                e = {next: t(0), throw: t(1), return: t(2)};
            return (
                "function" == typeof Symbol &&
                    (e[Symbol.iterator] = function () {
                        return this;
                    }),
                e
            );
            function t(t) {
                return function (e) {
                    return (function (t) {
                        if (i) throw new TypeError("Generator is already executing.");
                        for (; s; )
                            try {
                                if (
                                    (1,
                                    (i = 1),
                                    r &&
                                        (a =
                                            2 & t[0]
                                                ? r.return
                                                : t[0]
                                                ? r.throw || ((a = r.return) && a.call(r), 0)
                                                : r.next) &&
                                        !(a = a.call(r, t[1])).done)
                                )
                                    return a;
                                switch (((r = 0), (t = a ? [2 & t[0], a.value] : t)[0])) {
                                    case 0:
                                    case 1:
                                        a = t;
                                        break;
                                    case 4:
                                        return s.label++, {value: t[1], done: !1};
                                    case 5:
                                        s.label++, (r = t[1]), (t = [0]);
                                        continue;
                                    case 7:
                                        (t = s.ops.pop()), s.trys.pop();
                                        continue;
                                    default:
                                        if (
                                            !(a = 0 < (a = s.trys).length && a[a.length - 1]) &&
                                            (6 === t[0] || 2 === t[0])
                                        ) {
                                            s = 0;
                                            continue;
                                        }
                                        if (3 === t[0] && (!a || (t[1] > a[0] && t[1] < a[3]))) {
                                            s.label = t[1];
                                            break;
                                        }
                                        if (6 === t[0] && s.label < a[1]) {
                                            (s.label = a[1]), (a = t);
                                            break;
                                        }
                                        if (a && s.label < a[2]) {
                                            (s.label = a[2]), s.ops.push(t);
                                            break;
                                        }
                                        a[2] && s.ops.pop(), s.trys.pop();
                                        continue;
                                }
                                t = o.call(n, s);
                            } catch (e) {
                                (t = [6, e]), (r = 0);
                            } finally {
                                i = a = 0;
                            }
                        if (5 & t[0]) throw t[1];
                        return {value: t[0] ? t[1] : void 0, done: !0};
                    })([t, e]);
                };
            }
        };
Object.defineProperty(n, "__esModule", {value: !0}), (n.targetItemState = void 0);
var c,
    l = e("index"),
    u = e("player-theme"),
    p = e("game"),
    h = cc._decorator,
    t = h.ccclass,
    e = h.property;
((h = c = n.targetItemState || (n.targetItemState = {}))[(h.next = 1)] = "next"),
    (h[(h.over = 2)] = "over"),
    (h[(h.no = 3)] = "no");
var d,
    t =
        ((d = cc.Component),
        i(f, d),
        (f.prototype.onLoad = function () {
            var n = this;
            (this.animClips = this.itemAnimation.getClips()),
                this.animClips.length < 3 && console.log("error...this.animClips.length:", this.animClips.length),
                this.itemAnimation.on(cc.Animation.EventType.FINISHED, function (e, t) {
                    t.name === n.animClips[2].name
                        ? (n.itemAnimation.play(n.animClips[0].name), n.nextMoveEnd && n.nextMoveEnd())
                        : t.name === n.animClips[1].name && n.overMoveEnd && n.overMoveEnd();
                }),
                this.reseat();
        }),
        (f.prototype.setLabel = function (e) {
            (this.curNum = e),
                this.label && this.loadTargetLabel(),
                this.number && (this.number.string = this.curNum.toString());
        }),
        (f.prototype.loadTargetLabel = function () {
            return a(this, void 0, void 0, function () {
                var t, n;
                return s(this, function (e) {
                    switch (e.label) {
                        case 0:
                            return (
                                (t = u.playerTheme.getCoinLabelNames()),
                                this.curNum - 1 < 0 || this.curNum - 1 >= t.length
                                    ? (console.error("loadCoinLabel error this.curNum:", this.curNum), [2])
                                    : ((n = t[this.curNum - 1]), [4, l.ResUtil.loadSpritFrame("Texture/" + n)])
                            );
                        case 1:
                            return (n = e.sent()), (this.label.spriteFrame = n), [2];
                    }
                });
            });
        }),
        (f.prototype.getNum = function () {
            return this.curNum;
        }),
        (f.prototype.getSpriteIdx = function (e) {
            var t = Math.floor((this.curNum - 1) / e);
            return this.curNum - t * e - 1;
        }),
        (f.prototype.setNext = function (e, t, n) {
            var o = this;
            (this.nextSprite.spriteFrame = t),
                this.curState !== c.next &&
                    ((this.overNode.active = !1),
                    (this.nextNode.opacity = 0),
                    (this.nextNode.active = !0),
                    this.label && (this.label.node.active = !0),
                    (this.curState = c.next),
                    e
                        ? (this.label && this.label.setMaterial(0, this.normalMaterial),
                          this.number &&
                              ((t = p.default.ins.getColors()),
                              (e = Math.floor((this.curNum - 1) / t.length)),
                              (e = this.curNum - e * t.length),
                              (this.number.node.color = t[e - 1])),
                          this.itemAnimation.play(this.animClips[0].name))
                        : (this.scheduleOnce(function () {
                              var e, t;
                              o.label && o.label.setMaterial(0, o.normalMaterial),
                                  o.number &&
                                      ((e = p.default.ins.getColors()),
                                      (t = Math.floor((o.curNum - 1) / e.length)),
                                      (t = o.curNum - t * e.length),
                                      (o.number.node.color = e[t - 1]));
                          }, 1 / 3),
                          (this.nextMoveEnd = n),
                          this.itemAnimation.play(this.animClips[2].name)));
        }),
        (f.prototype.setOver = function (e, t) {
            var n = this;
            this.curState !== c.over &&
                ((this.curState = c.over),
                (this.node.scale = 1),
                e
                    ? ((this.overNode.active = !0),
                      (this.overNode.opacity = 255),
                      (this.nextNode.active = !1),
                      this.label && (this.label.node.active = !1),
                      this.number && (this.number.node.active = !1),
                      (this.node.getComponent(cc.Sprite).spriteFrame = this.overSpriteFrame))
                    : ((this.overNode.opacity = 0),
                      (this.nextNode.opacity = 0),
                      (this.overNode.active = !0),
                      (this.nextNode.active = !0),
                      (this.overMoveEnd = t),
                      this.itemAnimation.play(this.animClips[1].name),
                      this.scheduleOnce(function () {
                          n.label && (n.label.node.active = !1), n.number && (n.number.node.active = !1);
                      }, 1 / 3)));
        }),
        (f.prototype.reseat = function () {
            this.itemAnimation.stop(),
                (this.curState = c.no),
                (this.nextNode.active = !1),
                (this.overNode.active = !1),
                (this.overNode.opacity = 255),
                (this.nextNode.opacity = 255),
                4 <= this.animClips.length && this.itemAnimation.play(this.animClips[3].name),
                (this.node.getComponent(cc.Sprite).spriteFrame = this.normalSpriteFrame),
                (this.node.scale = 0.6),
                this.label &&
                    ((this.label.node.active = !0),
                    (this.label.node.scale = 1),
                    (this.label.node.opacity = 255),
                    this.label.setMaterial(0, this.grayMaterial)),
                this.number &&
                    ((this.number.node.active = !0),
                    (this.number.node.scaleX = 1),
                    (this.number.node.scaleY = 0.6),
                    (this.number.node.opacity = 255),
                    (this.number.node.color = new cc.Color(40, 40, 40)));
        }),
        (f.prototype.getNextNode = function () {
            return this.nextNode || null;
        }),
        r([e(cc.Sprite)], f.prototype, "label", void 0),
        r([e(cc.Label)], f.prototype, "number", void 0),
        r([e(cc.Node)], f.prototype, "nextNode", void 0),
        r([e(cc.Node)], f.prototype, "overNode", void 0),
        r([e(cc.Animation)], f.prototype, "itemAnimation", void 0),
        r([e(cc.Sprite)], f.prototype, "nextSprite", void 0),
        r([e(cc.Material)], f.prototype, "normalMaterial", void 0),
        r([e(cc.Material)], f.prototype, "grayMaterial", void 0),
        r([e(cc.Color)], f.prototype, "nomalColor", void 0),
        r([e(cc.SpriteFrame)], f.prototype, "normalSpriteFrame", void 0),
        r([e(cc.SpriteFrame)], f.prototype, "overSpriteFrame", void 0),
        r([t], f));
function f() {
    var e = (null !== d && d.apply(this, arguments)) || this;
    return (
        (e.label = null),
        (e.number = null),
        (e.nextNode = null),
        (e.overNode = null),
        (e.itemAnimation = null),
        (e.nextSprite = null),
        (e.normalMaterial = null),
        (e.grayMaterial = null),
        (e.nomalColor = cc.Color.WHITE),
        (e.normalSpriteFrame = null),
        (e.overSpriteFrame = null),
        (e.curNum = 0),
        (e.animClips = null),
        (e.curState = c.no),
        (e.nextMoveEnd = null),
        (e.overMoveEnd = null),
        e
    );
}
n.default = t;
